/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.GenericServlet;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import movie.connection;

/**
 *
 * @author Satellite
 */
public class kuotaEdit extends GenericServlet {

    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        String kuota = req.getParameter("kuota");
        String rekening = req.getParameter("rekening");
        Proses p = new Proses();

        try {

            p.getDBConnection();
            Connection conn = p.conn;
            java.sql.Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
            String sql = "update penonton set kuota='" + kuota + "' where rekening = '" + rekening + "'";
            stmt.executeUpdate(sql);
            req.setAttribute("message", "Kuota pelanggan berhasil diupload");
            req.getRequestDispatcher("/editKuota.jsp").forward(req, res);
        } catch (SQLException ex) {
            req.setAttribute("message", "Kuota pelanggan gagal diupload");
            req.getRequestDispatcher("/editKuota.jsp").forward(req, res);
        }
    }
}
